<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>事件表管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript" src="/static/jquery/jquery.form.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#value").focus();
            $("#inputForm").validate({
                submitHandler: function (form) {
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });

        $(function(){
            $("#path").change(function () {
                $("#docPath").val($("#path").val());
                uploadPic();
            });
        })
        function uploadPic() {
            $('#btnSubmit').attr("disabled","disabled");
            $("#btnSubmit").val("文件上传中");
            var options={
                url:"/upload/uploadPic",
                type:"post",
                dataType:"text",
                success:function(data){
                    $("#url").val(data);
                    $("#btnSubmit").removeAttr("disabled");
                    $("#btnSubmit").val("保存");
                }
            }
            $("#inputForm").ajaxSubmit(options);
        }

        function change(v) {
            if(v=='9'){
                $("#message1").css('display','none');
                $("#new_message").css('display','block');
            }else{
                $("#message1").css('display','block');
                $("#new_message").css('display','none');
            }
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/business/event">课程事件表</a></li>
    <li class="active"><a href="${ctx}/business/event/form?id=${event.id}">课程事件表<shiro:hasPermission
            name="business:event:edit">${not empty event.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission
            name="business:event:view">查看</shiro:lacksPermission></a></li>
</ul>
<br/>
<form:form id="inputForm" modelAttribute="event" action="${ctx}/business/event/save" method="post"
           class="form-horizontal">
    <form:hidden path="id"/>
    <tags:message content="${message}"/>
    <div class="control-group">
        <label class="control-label">事件名称:</label>
        <div class="controls">
            <form:input path="name" name="name" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">序号:</label>
        <div class="controls">
            <form:input path="seq" name="seq" htmlEscape="false" maxlength="5" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">持续时间(秒):</label>
        <div class="controls">
            <form:input path="seconds" name="seconds" htmlEscape="false" maxlength="5" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">知识点数:</label>
        <div class="controls">
            <form:input path="knowledge" name="knowledge" htmlEscape="false" maxlength="5" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label">学期类型:</label>
        <div class="controls">
            <form:select path="formal" class="input-small required">
                <form:options items="${dic:getBusDictList('semester_formal')}" itemLabel="label" itemValue="value"
                              htmlEscape="false"/>
                <form:option value="2" label="全部"/>
            </form:select>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">事件类型:</label>
        <div class="controls">
            <form:select path="type" onchange="change(this.value)" class="input-small required">
                <form:option value="" label=""/>
                <form:options items="${dic:getBusDictList('event_type')}" itemLabel="label" itemValue="value"
                              htmlEscape="false"/>
            </form:select>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">文件地址:</label>
        <div class="controls">
            <input id="docPath" type="text" placeholder="点击选择文件">
            <input id="path" name="pic" style="cursor: pointer;width: 220px;height:30px;margin-left: -222px;  opacity: 0; filter:alpha(opacity=0)" class="form-control" type="file">
            <input id="url" name="url" type="hidden">

        </div>
    </div>

    <div class="control-group">
        <label class="control-label">事件描述:</label>
        <div class="controls">
            <form:textarea path="description" htmlEscape="false" class="span6 required"
                           placeholder="请填写描述！"/>
            <tags:ckeditor replace="description" uploadPath="/upload/file"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label">完成通知标题:</label>
        <div class="controls">
            <form:input path="title" name="title" htmlEscape="false" maxlength="200" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">完成通知内容:</label>
        <div class="controls">
            <form:textarea path="message" name="message" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>

        </div>
    </div>

    <hr>
    <div id="message1" <c:if test="${event.type=='9'}">style="display: none"</c:if>>
    <div class="control-group">
        <label class="control-label">微信消息标题:</label>
        <div class="controls">
            <form:input path="wxfirst" name="wxfirst" htmlEscape="false" maxlength="250" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">通知类型:</label>
        <div class="controls">
            <form:input path="wxkeyword1" name="wxkeyword1" htmlEscape="false" maxlength="200" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">通知内容:</label>
        <div class="controls">
            <form:input path="wxkeyword2" name="wxkeyword2" htmlEscape="false" maxlength="200" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">消息备注:</label>
        <div class="controls">
            <form:textarea path="wxremark" name="wxremark" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
            <span class="help-inline"><font color="red">*</font> </span>

        </div>
    </div>
    </div>
    <div id="new_message" <c:if test="${event.type!='9'}">style="display: none"</c:if>>
        <div class="control-group">
            <label class="control-label">微信消息标题:</label>
            <div class="controls">
                <form:input path="wxtitle" name="wxtitle" htmlEscape="false" maxlength="100" class="input-xlarge"/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">链接:</label>
            <div class="controls">
                <form:input path="wxurl" name="wxurl" htmlEscape="false" placeholder="this默认本条" maxlength="150" class="input-xlarge "/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">图片:</label>
            <div class="controls">
                <form:input path="wxpic" name="wxpic" htmlEscape="false" maxlength="150" class="input-xlarge "/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">消息内容:</label>
            <div class="controls">
                <form:textarea path="wxcontent" name="wxcontent" htmlEscape="false" maxlength="100" class="input-xlarge "/>
            </div>
        </div>
    </div>
    <div class="form-actions">
        <shiro:hasPermission name="business:event:edit">
            <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
        </shiro:hasPermission>
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
    </div>
</form:form>
</body>
</html>